<template>
	<view class="content">
		<view v-if="!data.utype">
			<u-navbar :is-back="false" :border-bottom="false"></u-navbar>
			<view class="content_swiper">
				<u-swiper :list="data.list" :height="900" img-mode="aspectFit" mode="none"></u-swiper>
			</view>
			<view class="content_btm">
				<u-button :custom-style="data.customStyle" hover-class="none" :ripple="false" :hair-line="false"
					@click="toLogin('2')">我要求职</u-button>
				<u-button :custom-style="data.customStyle" hover-class="none" :ripple="false" :hair-line="false"
					@click="toLogin('1')">我要招聘</u-button>
			</view>
		</view>
		<!-- 用户选择过身份后 未填写简历信息或简历信息不完整 或  未填写企业信息或未认证 -->
		<view v-else>
			<u-navbar :is-back="false" title="微靖江招聘平台" :border-bottom="false"></u-navbar>
			<view class="content_item u-m-t-30">
				<u-image src="/pages/login/static/status_1.png" :width="300" :height="300" mode="widthFix"></u-image>
				<u-button :custom-style="data.style" hover-class="none" :hairLine="false" :ripple="false"
					@click="statusChange(2)">我要找工作</u-button>
			</view>
			<u-divider half-width="250" margin-top="36" margin-bottom="36">或者</u-divider>
			<view class="content_item">
				<u-image src="/pages/login/static/status_1.png" :width="300" :height="300" mode="widthFix"></u-image>
				<u-button :custom-style="data.style" hover-class="none" :hairLine="false" :ripple="false"
					@click="statusChange(1)">我要招人</u-button>
			</view>
			<view class="content_logout" :style="data.logoutStyle" @click="data.loginshow = true">
				退出登录
			</view>
		</view>

		<u-modal v-model="data.loginshow" title="系统提示" content="确定要退出吗？更多好工作，尽在微靖江人才网" confirmText="确定" showCancelButton
			@confirm="$u.throttle(confirm, 1000)"></u-modal>
	</view>
</template>

<script setup>
	import {
		reactive,
		ref
	} from "vue";
	import {
		useUserStore
	} from '/stores/userInfo.js'
	import {
		onShow
	} from '@dcloudio/uni-app'
	const useUser = useUserStore()
	const data = reactive({
		utype: 0,
		list: ['/pages/login/static/welcome1.png', '/pages/login/static/welcome2.png',
			'/pages/login/static/welcome3.png'
		],
		customStyle: {
			color: '#00D075',
			borderColor: '#00D075',
			height: '51px',
			width: '134px',
			fontSize: '16px',
			fontFamily: 'SourceHanSansSC-regular'
		},
		style: {
			marginTop: '96rpx',
			width: '468rpx',
			backgroundColor: '#00D075',
			border: 'none',
			color: '#fff'
		},
		logoutStyle: {

		},
		loginshow: false
	})
	onShow(() => {
		data.utype = uni.getStorageSync('utype')
	})
	const statusChange = async (utype) => {
		if (data.utype == utype) {
			let next_code = uni.getStorageSync('next_code')
			if (next_code == 50007) { //没有简历信息
				uni.$u.route({
					type: 'reLaunch',
					url: 'pages/pagesPersonal/Initial/Initial'
				})
			} else if (next_code == 50003) { // 没有企业信息
				uni.$u.route('/pages/pagesPersonal/companyInfo/initCompanyInfo')
			} else if (next_code == 50005) { // 简历信息不完整
				uni.$u.route({
					type: 'reLaunch',
					url: '/pages/pagesPersonal/myResume/myResume'
				})
			} else {
				uni.$u.route({
					type: 'tab',
					url: '/pages/home/home'
				})
			}
		} else {
			uni.$u.route({
				type: 'reLaunch',
				url: 'pages/login/login',
				params: {
					utype: data.utype == 1 ? 2 : 1
				}
			})
		}
	}
	// 退出账号
	const confirm = () => {
		uni.$u.toast('退出成功')
		useUser.getLogout()
	}
	// 去登录页并存储当前身份
	const toLogin = (utype) => {
		uni.setStorageSync('utype', utype)
		uni.$u.route({
			type: 'tab',
			url: 'pages/home/home'
		})
	}
</script>

<style lang="scss" scoped>
	.content {
		&_swiper {
			padding: 40rpx 80rpx 0;
		}

		&_btm {
			position: fixed;
			bottom: 88rpx;
			left: 0;
			width: 100%;
			padding: 0 60rpx;
			box-sizing: border-box;
			display: flex;
			align-items: center;
			justify-content: space-between;
		}

		&_item {
			display: flex;
			flex-direction: column;
			align-items: center;
			justify-content: center;
		}

		&_logout {
			text-align: center;
			color: #00D075;
			font-size: 28rpx;
			position: fixed;
			/* #ifndef MP-WEIXIN */
			bottom: 0;
			padding-bottom: 50rpx;
			/* #endif */
			/* #ifdef MP-WEIXIN */
			bottom: 20rpx;
			padding-bottom: 50rpx;
			/* #endif */
			width: 100vw;
		}
	}
</style>